package com.zf.sqlite.utils;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

@Dao
public interface BlacklistDao {
    @Query("SELECT * FROM zfed_backlist ORDER BY backlist_add_time DESC")
    List<BlacklistEntity> getAllBlacklist();

    @Query("SELECT * FROM zfed_backlist WHERE type = :type ORDER BY backlist_add_time DESC")
    List<BlacklistEntity> getBlacklistByType(int type);

    @Query("SELECT * FROM zfed_backlist WHERE device_mac = :mac")
    BlacklistEntity getBlacklistByMac(String mac);

    @Insert
    void insertBlacklist(BlacklistEntity blacklist);

    @Update
    void updateBlacklist(BlacklistEntity blacklist);

    @Delete
    void deleteBlacklist(BlacklistEntity blacklist);

    @Query("DELETE FROM zfed_backlist WHERE id = :id")
    void deleteBlacklistById(long id);

    @Query("DELETE FROM zfed_backlist")
    void deleteAllBlacklist();
}
